import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';

class MyApp18 extends StatefulWidget {
  const MyApp18({super.key});

  @override
  State<MyApp18> createState() => _MyApp18State();
}

class _MyApp18State extends State<MyApp18> {
  @override
  void initState() {
    // implement initState
    loadData();
    super.initState();
  }

  loadData() async {
    final dio = Dio();
    Response res = await dio.get('https://mock.boxuegu.com/mock/1172/orders');
    // print(res.data);

    final logger = Logger(
      printer: PrettyPrinter(
        methodCount: 2, // Number of method calls to be displayed
        errorMethodCount: 8, // Number of method calls if stacktrace is provided
        lineLength: 120, // Width of the output
        colors: true, // Colorful log messages
        printEmojis: false, // Print an emoji for each log message
      ),
    );
    // logger.t("Trace log");

    // logger.d("Debug log");

    // logger.i("Info log");

    // logger.w("Warning log");

    // logger.e("Error log", error: 'Test Error');

    // logger.f("What a fatal log");

    logger.i(res.data);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('dio练习'),
          centerTitle: true,
        ),
        body: Center(
          child: Text('内容'),
        ),
      ),
    );
  }
}
